package com.dylan.redislimiting.controller;

import com.dylan.redislimiting.annotation.LimitType;
import com.dylan.redislimiting.annotation.RateLimiting;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 限流测试控制器
 *
 * @author zhangshaojian
 * @date 2022/7/22 18:30
 */
@RestController
public class RateLimitingController {

    @GetMapping
    @RateLimiting(prefix = "order", key = "limit:list", period = 5, count = 1, limitType = LimitType.CUSTOMER)
    public String sayHi() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return "hello world!    " + format.format(new Date());
    }
}
